// 导入组件
import Vue from 'vue';
import Router from 'vue-router';
// 登录
import login from '@/views/login';
// 首页
import index from '@/views/index';
/**
 * 基础菜单
 */

import Activity from '@/views/activity/list';
import UserApplication from '@/views/activity/applicationList';
import Question from '@/views/question/list';
import Certificate from '@/views/certificate/list';
import ImgUpload from '@/views/upload/img';
import UserList from '@/views/user/list';

// 启用路由
Vue.use(Router);

// 重复点击路由
const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

// 导出路由 
export default new Router({
    routes: [{
        path: '/',
        name: '',
        component: login,
        hidden: true,
        meta: {
            requireAuth: false
        }
    }, {
        path: '/login',
        name: '登录',
        component: login,
        hidden: true,
        meta: {
            requireAuth: false
        }
    }, {
        path: '/index',
        name: '首页',
        component: index,
        iconCls: 'el-icon-tickets',
        children: [{
            path: '/activity/list',
            name: '考证列表',
            component: Activity,
            meta: {
                requireAuth: true
            }
        }, {
            path: '/activity/applicationList',
            name: '报名名单',
            component: UserApplication,
            meta: {
                requireAuth: true
            }
        }, {
            path: '/question/list',
            name: '题库列表',
            component: Question,
            meta: {
                requireAuth: true
            }
        }, {
            path: '/certificate/list',
            name: '等级认证列表',
            component: Certificate,
            meta: {
                requireAuth: true
            }
        }, {
            path: '/img/upload',
            name: '上传图片接口',
            component: ImgUpload,
            meta: {
                requireAuth: true
            }
        }, {
            path: '/user/list',
            name: '用户列表',
            component: UserList,
            meta: {
                requireAuth: true
            }
        }]
    }]
})